<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use App\Model\TpItemBuildingHxCaseStyle;
use App\Model\TpItemWebCfg;
use App\Traits\ApiResponseTrait;
use Hyperf\HttpServer\Contract\RequestInterface;
use Psr\Http\Message\ResponseInterface;

class IndexController extends AbstractController
{
    use ApiResponseTrait;

    public function index(RequestInterface $request): ResponseInterface
    {
        $res = TpItemWebCfg::query()->where('id',5)->first();
        $arr = $res->cnt;
        foreach ($arr as $key => $value) {
            if ($value['arrType'] !=[]) {
                if (!in_array(1249, $value['arrType'])) {
                    unset($arr[$key]);
                }
            }

        }
        return $this->success(array_values($arr));
    }

    public function ceshi()
    {
        $data = TpItemBuildingHxCaseStyle::query()->with(['hxCase' => function ($query) {
            return $query->with('goods:id,case_id,goods_price')->select('id');
        }])
            ->where('case_ids', 16382389572651954)
            ->groupBy('case_style_id')
            ->get();
        return $this->success($data);
    }
}
